<%@include file="ValidarSession.jsp"%>
<%@include file="cabecera.jsp"%>

<p>
	<strong>Mantenimiento de Empresa &gt; Editar</strong>
</p>
<form id="form1" name="form1" method="post" action="EmpresaModificarServlet">
	<%@page import="bt.modelo.Empresa;"%>
	<%
		Empresa vo = (Empresa) request.getAttribute("vo");
	%>
	<table border="1" cellpadding="0" cellspacing="0">
		<tr>
			<td>Razon Social</td>
			<td><label> <input type="text" name="razonSocial"
					id="razonSocial" style="width: 300px;"
					value="<%=vo.getRazonsocial()%>" readonly="readonly" /> </label>
			</td>
			<td>Direccion</td>
			<td><label> <input type="text" name="direccion"
					id="direccion" style="width: 300px;"
					value="<%=vo.getDireccion()%>" /> </label>
			</td>
		</tr>
		<tr>
			<td>Pais</td>
			<td><select name="cmbPais">
					<c:forEach items="${USUARIO_PAISES}" var="p">
					    <c:set var="a" value="${p.idPais }" />
					    <c:set var="b" value="<%=vo.getIdPais()%>" />		
					    <c:if test="${a==b}">
					         <option selected="selected" value="${p.idPais }">${p.nombre }</option>					         
					    </c:if>
					    <c:if test="${a!=b}">
					         <option value="${p.idPais }">${p.nombre }</option>					         
					    </c:if>					
					</c:forEach>
			</select>
			</td>
			<td>Departamento</td>
			<td><select name="cmbDepa">
					<c:forEach items="${USUARIO_DEPAS}" var="d">
					    <c:set var="a" value="${d.idDepartamento}" />
					    <c:set var="b" value="<%=vo.getIdDepartamento()%>" />		
					    <c:if test="${a==b}">
					         <option selected="selected" value="${d.idDepartamento }">${d.nombre }</option>					         
					    </c:if>
					    <c:if test="${a!=b}">
					         <option value="${d.idDepartamento }">${d.nombre }</option>					         
					    </c:if>							
					</c:forEach>
			</select>
			</td>
		</tr>
		<tr>
			<td>Rubro</td>
			<td><select name="cmbRubro">			       
					<c:forEach items="${USUARIO_RUBROS}" var="r">
					    <c:set var="a" value="${r.idRubro}" />
					    <c:set var="b" value="<%=vo.getIdRubro()%>" />		
					    <c:if test="${a==b}">
					         <option selected="selected" value="${r.idRubro }">${r.descripcion }</option>					         
					    </c:if>
					    <c:if test="${a!=b}">
					         <option value="${r.idRubro }">${r.descripcion }</option>					         
					    </c:if>		
					</c:forEach>
			</select>
			</td>
			<td>Contacto</td>
			<td><label> <input type="text" name="contacto"
					id="contacto" style="width: 300px;" value="<%=vo.getContacto()%>" />
			</label>
			</td>
		</tr>
		<tr>
			<td>Email</td>
			<td><label> <input type="text" name="correo" id="correo"
					style="width: 300px;" value="<%=vo.getEmailcontacto()%>" /> </label>
			</td>
			<td>Sector</td>
			<td><label> <input type="text" name="sector" id="sector"
					style="width: 300px;" value="<%=vo.getSector()%>" /> </label>
			</td>
		</tr>
		<tr>
			<td>RUC</td>
			<td><label> <input type="text" name="ruc" id="ruc"
					style="width: 300px;" value="<%=vo.getRuc()%>" /> </label>
			</td>
			<td>Password</td>
			<td><label> <input type="password" name="clave"
					id="clave" style="width: 100px;" value="<%=vo.getPassword()%>" />
			</label>
			</td>
		</tr>
		<tr>
			<td colspan="4"><input type="submit" value="Guardar"
				onclick="return isValidEmail();" /> <input type="button"
				value="Regresar" onclick="window.location='empBuscar.jsp' " /></td>
		</tr>
	</table>
	<p>&nbsp;</p>
</form>

<script type=text/javascript>
function isValidEmail(){
	var email = document.getElementById("correo").value;
	var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/;
	if (reEmail.test(email)){
		return true;
	} else {
		alert("Correo electronico invalido.");
		document.getElementById("correo").focus();
		return false;
	}
}
</script>
<%@include file="pie.jsp"%>
